package com.kg.fiber.view;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Font;

import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.ListSelectionModel;
import javax.swing.table.TableColumn;
import javax.swing.table.TableColumnModel;

import com.kg.fiber.FiberviewApplication;
import com.kg.fiber.service.NodeBoss;

public class NodesPanel extends JPanel {

	/**
	 * 
	 */
	private static final long serialVersionUID = 3647579846725472636L;
	private JTable table;

	/**
	 * Create the panel.
	 */
	public NodesPanel() {
		setLayout(new BorderLayout(0, 0));
		
		JPanel panel = new JPanel();
		panel.setVisible(false);
		add(panel, BorderLayout.NORTH);
		panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS));
		
		Component horizontalStrut = Box.createHorizontalStrut(10);
		panel.add(horizontalStrut);
		
		JLabel lblNewLabel = new JLabel("监测节点：");
		lblNewLabel.setForeground(Color.DARK_GRAY);
		lblNewLabel.setFont(new Font("微软雅黑", Font.PLAIN, 18));
		panel.add(lblNewLabel);
		
		Component horizontalGlue = Box.createHorizontalGlue();
		panel.add(horizontalGlue);
		
		JButton button = new JButton("+");
		panel.add(button);
		
		JButton button_1 = new JButton("-");
		panel.add(button_1);
		
		Component horizontalStrut_1 = Box.createHorizontalStrut(10);
		panel.add(horizontalStrut_1);
		
		JScrollPane scrollPane = new JScrollPane();
		add(scrollPane, BorderLayout.CENTER);
		
		table = new JTable();
		table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
		table.setRowHeight(40);
		table.setFont(new Font("微软雅黑", Font.PLAIN, 18));
		scrollPane.setViewportView(table);
		
		
		NodeBoss boss = FiberviewApplication.getSpring().getBean(NodeBoss.class);
		table.setModel(boss.getTableModel());
		
		TableColumnModel tcm = table.getColumnModel();
		
		TableColumn tc = tcm.getColumn(0);
		tc.setPreferredWidth(100);
		tc.setMaxWidth(100);
		
		tc = tcm.getColumn(1);
		tc.setPreferredWidth(200);
		tc.setMaxWidth(200);

		table.setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN);
	}
	
	

}
